import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;


public class Access{

	String monNom;
	Score monScore;
	
//	public MySQL(String temps){
//		monNom = JOptionPane.showInputDialog(null, "Veuillez saisir votre pseudo"); 
//
//	}
	
	public Access(String temps){
		InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "Sauvergarder votre temps","Veuillez saisir votre pseudo", "", null);
		
		if(dlg.open() == Window.OK)
			{
			try {
				// The newInstance() call is a work around for some
				// broken Java implementations
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
				} catch (Exception ex) {
				// handle the error
					System.out.println("erreur");
				}
			String url = "jdbc:odbc:Sudoku";
			
			
				Connection con;
				try {
					con = DriverManager.getConnection(url,"" ,"" );
					
					
					java.sql.Statement stmt = con.createStatement();
					
					stmt.executeUpdate("INSERT INTO Score (Pseudo,Temps) VALUES ('"+ dlg.getValue() + "','" + temps+"')") ; 
					
					con.close();
					monScore = new Score(dlg.getValue(), temps);
					
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				
			}
		else
			monScore = new Score("", "");
		
	}
	
	
}
	
